const state = {
address:uni.getStorageSync('add')||{},
token:uni.getStorageSync('userToken') ||'',
userInfo:uni.getStorageSync('userInfo') || {},
redirectInfo:null
}
const mutations = {
  setRedirectInfo(state,data){
    state.redirectInfo = data
  },
  changeToken(state,data){
    state.token = data
    uni.setStorageSync('userToken',data)
  },
  setUserInfo(state,data){
    state.userInfo = data
    uni.setStorageSync('userInfo',data)
  },
  setaddress(state,data){
    state.address = data
    uni.setStorageSync('add',state.address)
    // console.log(state.address);
  }
}
const actions = {
  logOut({commit}){
    commit('setUserInfo',{})
    commit('changeToken','')
    commit('setaddress',{})
  }
}
const getters = {
  fullAddress(state){
    if(!state.address.provinceName) return ''
    return state.address.provinceName + state.address.cityName + state.address.countyName + state.address.detailInfo
  }
}
export default {
  namespaced:true,
  state,
  mutations,
  actions,
  getters
}